#ifndef CLIENTITEM_H
#define CLIENTITEM_H

#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QEnterEvent>

enum E_MOUSE_TYPE
{
    E_ENTER,
    E_LEAVE
};

class ClientItem : public QWidget
{
    Q_OBJECT
public:
    explicit ClientItem(QWidget *parent = nullptr);
    void setClientIP(QString ip);
    void setClientName(QString name);
    void setOnLineStat(bool isOnline);
    void setUnReadMsg();
    void setUnSelecte();
    QString getClientIP();
    QString getClientName();

protected:
    void paintEvent(QPaintEvent *event) override;
    void enterEvent(QEvent *event) override;
    void leaveEvent(QEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;

signals:
    void signal_OpenChatWidget(QString clientIP);

private:
    int m_MouseStat = E_LEAVE;
    bool m_IsOnLine = true;
    QString m_ClientIP = "";
    QString m_ClientName = "";
    int m_UnReadMsgNum = 0;
    bool m_IsSelected = false;

    void drawClientStat(QPainter &painter);
    void drawClientIP(QPainter &painter);
    void drawUnReadMsgNum(QPainter &painter);
    void drawBackground(QPainter &painter);
};

#endif // CLIENTITEM_H
